<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<!--Converted with LaTeX2HTML 96.1 (Feb 5, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->


<title>Factors and Factorials</title>
<meta name="description" content="Factors and Factorials">
<meta name="keywords" content="htmlatex">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<link rel="STYLESHEET" href="acm-00160_archivos/htmlatex.css">
</head><body bgcolor="#ffffff" lang="EN">
 <h1><br clear="all"><center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">Factors and Factorials</a></font>&nbsp;</b></td></tr></tbody></table></center></h1>
<p>
The factorial of a number <i>N</i> (written <i>N</i>!) is defined as the product of
all the integers from 1 to <i>N</i>. It is often defined recursively as
follows:
</p><p>
</p><p> <img alt="displaymath27" src="acm-00160_archivos/160img1.gif" align="bottom" height="13" width="272"> </p><p>
</p><p>
</p><p> <img alt="displaymath28" src="acm-00160_archivos/160img2.gif" align="bottom" height="18" width="319"> </p><p>
</p><p>
Factorials grow very rapidly--5! = 120, 10! = 3,628,800. One way of
specifying such large numbers is by specifying the number of times
each prime number occurs in it, thus 825 could be specified as (0 1 2
0 1) meaning no twos, 1 three, 2 fives, no sevens and 1 eleven.
</p><p>
</p><p>
Write a program that will read in a number <i>N</i> ( <img alt="tex2html_wrap_inline39" src="acm-00160_archivos/160img3.gif" align="middle" height="26" width="95"> ) and
write out its factorial in terms of the numbers of the primes it
contains.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001001000000000000000">Input</a></font></h2>
<p>
Input will consist of a series of lines, each line containing a single
integer <i>N</i>. The file will be terminated by a line consisting of a
single 0.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">Output</a></font></h2>
<p>
Output will consist of a series of blocks of lines, one block for each
line of the input. Each block will start with the number N, right
justified in a field of width 3, and the characters `<tt>!</tt>',
space, and `<tt>=</tt>'. This will
be followed by a list of the number of times each prime number occurs
in <i>N</i>!.
</p><p>
These should be right justified in fields of width 3 and each
line (except the last of a block, which may be shorter) should contain
fifteen numbers. Any lines after the first should be indented. Follow
the layout of the example shown below exactly.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001003000000000000000">Sample input</a></font></h2>
<p>
</p><pre>5
53
0</pre>
<p>
</p><h2><font color="#0070e8"><a name="SECTION0001004000000000000000">Sample output</a></font></h2>
<p>
</p><pre>  5! =  3  1  1
 53! = 49 23 12  8  4  4  3  2  2  1  1  1  1  1  1
        1</pre>
<p>
</p></body></html>